Demo Programs
This program uses the front-panel switches on the Altair 8800 to add two 4 bit numbers
Note that these programs were hand-assembled so the syntax may not be correct. They were entered into the computer using the front-panel switches. Hex values us the H suffix.
Overview
At their core computers are calculators so often the simplest program you can write is one that performs some arithmetic. In the case of the Altair the simplest input/output mechanism is the front-panel. This program combines these two things by creating an adder that users the front-panel for input and output.
Interface
The users enters in two values using the upper 8 switches on the front-panel. The left four switches specify one number and the right four specify the other number. The result of adding these values is then displayed using the upper 8 lights on the front of the Altair.
Read and Add
The left switches are set to 0101 which indicates a value of 5. The right switches are set to 0011 which indicates a value of 3. 5 + 3 = 8 which in binary is 1000. This is the value displayed on the front-panel lights.
Code
ReadAddAndLoop.asm
The program starts by reading in the value from the front-panel switches by performing an IN FFH instruction. FFH is a special address for reading the switches. It then saves this value in the B register and AND's the value with 0FH to clear the high bits. This is the number from the right switches and gets saved in the C register. The switch value is then restored from the B register. That number is then rotated right four times and AND'd to get the high-order bits. This is the number from the left switches. The value in the accumulator is then added to the C register to calculate the left switches number plus the right switches number. The result is then moved into the D register. It then repeatedly executes LDAX D. This causes the address in the DE register pair to be shown on the front-panel lights.